/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package presentacion.utilidad.event_queue;

// @author Santhosh Kumar T - santhosh@in.fiorano.com

import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.text.JTextComponent;

class PasteAction extends AbstractAction{
    JTextComponent comp;

    public PasteAction(JTextComponent comp){
        super("Pegar");
        this.comp = comp;
    }

    public void actionPerformed(ActionEvent e){
        comp.paste();
    }

    public boolean isEnabled(){
        if (comp.isEditable() && comp.isEnabled()){
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
            return contents.isDataFlavorSupported(DataFlavor.stringFlavor);
        }else
            return false;
    }
} 